<!DOCTYPE html>
<html>

<head>
  <meta charset="utf-8" />
  <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1" />
  <meta name="renderer" content="webkit" />
  <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no" />
  <title>千峰教育大前端Vue教学</title>
  <script src="https://cdn.staticfile.org/petite-vue/0.4.1/petite-vue.umd.min.js"></script>
</head>

<body style="margin:100px;font-size:22px;">
  <div v-scope="Child({ name: '第一个', age: 5 })">
    <div>name = {{ name }}</div>
    <div>age = {{ age }}</div>
    <hr>
  </div>
  <hr>
  <div v-scope="Child({ name: '第二个', age: 10 })">
    <div>name = {{ name }}</div>
    <div>age = {{ age }}</div>
    <hr>
  </div>

  <template id="child">
    <div>我是子组件，我叫 {{ name }}, 今年 {{ age }} 岁</div>
    <button @click="grow">过生日</button>
  </template>

  <script>
    function Child(props) {
      return {
        ...props,
        $template: '#child',
        grow() {
          this.age++
        },
      }
    }
    PetiteVue.createApp({
      Child, // 注册组件
    }).mount()
  </script>
</body>

</html>